import {View, StyleSheet, Button} from 'react-native';
import React, {useCallback} from 'react';
import {useDispatch} from 'react-redux';

const style = StyleSheet.create({
  buttonView: {
    flex: 1,
    justifyContent: 'space-between',
    backgroundColor: '#f40',
    padding: 20,
    margin: 10,
  },
});
export default function GetDataButton() {
  const dispatch = useDispatch();
  const onClick = useCallback(e => {
    dispatch({type: 'user/getButtonData', payload: {userId: 123}}); // 异步获取数据
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  return (
    <View style={style.buttonView}>
      <Button onPress={onClick} title="获取数据" />
    </View>
  );
}
